package com.twotiger.and.util;

import android.view.View;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;

public class KeyboradListener {
    private static boolean isshow = true;

    public static boolean isshow(final View view) {
        view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                int heightDiff = view.getRootView().getHeight() - view.getHeight();
                LogUtil.info("detailMainRL.getRootView().getHeight() = "
                             + view.getRootView().getHeight());
                LogUtil.info("detailMainRL.getHeight() = " + view.getHeight());
                if (heightDiff > 100) { // 说明键盘是弹出状态
                    LogUtil.info("键盘弹出状态");
                    isshow = true;
                } else {
                    LogUtil.info("键盘收起状态");
                    isshow = false;
                }
            }
        });
        return isshow;
    }
}
